//: Playground - noun: a place where people can play

import UIKit

func about() {
    print("about");
}

func about2() -> String {
    return "about";
}

func about3(str: String) {
    print("about \(str)")
}

about();
print(about2());
print(about3(str: "9999"));

// 函数的默认参数
func sayHello(name: String = "XXX") {
    print("hello  \(name)")
}

sayHello();
sayHello(name: "xiaoming");


// 函数的可变参数
func sayHello(to persons:String...) {
    for person in persons {
        print("hello \(person)")
    }
}

sayHello(to: "zhangsan", "lisi")

 
func maxMin(numbers: Int ...) -> (max: Int, min: Int)? {
    if numbers.count == 0 {
        return nil;
    }
    var maxV = numbers.first, minV = numbers.first;
    for item in numbers {
        if item>maxV! {
            maxV = item;
        }
        
        if item<minV! {
            minV = item;
        }
    }
    return (maxV!, minV!);
}

let result = maxMin(numbers: 1,2,3,4,5,6,7,8,9)
result?.max
result?.min


// swift 是值传递
func swap (a: inout Int, b: inout Int) {
    let tmp = a;
    a = b;
    b = tmp;
}

var a = 10;
var b = 20;
swap(&a, &b);
a
b

func test() {
    
}

